<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Add</title>
</head>
<body>
<div id="Add">
    <div>
        <input type="text" placeholder="id" v-model="id">
        <input type="text" placeholder="名称" v-model="name">
        <input type="text" placeholder="单价" v-model="price">
        <input type="text" placeholder="品牌" v-model="brand">
    </div>
    <div>
        <button @click="add">提交</button>
    </div>
</div>
<script>
    let vue = new Vue({
        el: "#add",
        data: {
            id: '',
            name: '',
            price: '',
            brand: '',
        },
        methods: {
            add() {
                $.ajax('/studentAdd', {
                    method: 'post',
                    data: {
                        id: this.id,
                        name: this.name,
                        price: this.price,
                        brand: this.brand,
                    },
                    success: data => {
                        if (data.code == 200) {
                            // window.open('/vuepage','_self');
                            window.location.href = '/main';
                        }
                    }
                })

            }
        }

    })
</script>
</body>
</html>